import {observable as o, computed as c, action as a} from 'mobx';
import _ from 'lodash';
import axios from 'core/axios';
import RootStore from 'core/Store.js';
import request from 'core/request.js';
import Im from 'immutable';
import {browserHistory} from 'react-router';

class Store extends RootStore {
    constructor(args) {
        super(args);
    }

    will() {

    }

    @o userIncome = {};
    @o orderIncome = {};

    getUserAndOrderTotal() {
        request({url: $$.api('getIncomeUser')}).then(res => {
            this.userIncome = res.data;
        }).catch(err => {
            this.stores.Message.fire('message', {
                type: $$.SEM.ERROR_TEXT,
                text: err.message
            });
        });
        request({url: $$.api('getIncomeOrder')}).then(res => {
            this.orderIncome = res.data;
        }).catch(err => {
            this.stores.Message.fire('message', {
                type: $$.SEM.ERROR_TEXT,
                text: err.message
            });
        });
    }


    mount() {
        this.getUserAndOrderTotal();
    }

}

export default Store;